<script lang="ts" setup>
import {ElCheckbox} from "element-plus";

const props = defineProps(['data', 'modelVal'])
const emit = defineEmits(['update:modelVal'])

const change = (checked: boolean, label: string) => {
  emit('update:modelVal', checked ? [...props.modelVal, label] : props.modelVal.filter(item => item !== label))
}
</script>

<template>
  <div class="flex">
    <div>{{ data.label }}</div>
    <el-checkbox v-if="!data.children" @change="change($event,data.label)"/>
  </div>
</template>